<!DOCTYPE html><html class=split lang=en-US-x-hixie><script src=../link-fixup.js defer=""></script>
<!-- Mirrored from html.spec.whatwg.org/multipage/comms.html by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 10 Sep 2025 08:35:54 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<meta charset=utf-8><meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name=viewport><title>HTML Standard</title><meta content=#3c790a name=theme-color><meta content="light dark" name=color-scheme><link rel=stylesheet href=../../resources.whatwg.org/standard-shared-with-dev.css crossorigin=""><link rel=stylesheet href=../../resources.whatwg.org/standard.css crossorigin=""><link rel=stylesheet href=../../resources.whatwg.org/spec.css crossorigin=""><link rel=icon href=https://resources.whatwg.org/logo.svg crossorigin=""><link rel=stylesheet href=../styles.css crossorigin=""><script>
   function toggleStatus(div) {
     div.parentNode.classList.toggle('wrapped');
   }
   function setLinkFragment(link) {
     link.hash = location.hash;
   }
  </script><body>
  
  <script defer="" crossorigin="" src=../html-dfn.js></script>
  
  <header id=head class="head with-buttons">
   <a href=https://whatwg.org/ class=logo><img width=100 alt=WHATWG crossorigin="" class=darkmode-aware src=https://resources.whatwg.org/logo.svg height=100></a>
   <hgroup><h1 class=allcaps>HTML</h1><p id=living-standard>Living Standard — Last Updated <span class=pubdate>10 September 2025</span></hgroup>
   
   

   
  </header>

  

  

  

  
  

  
  

  

  <nav><a href=imagebitmap-and-animations.html>← 8.10 Images</a> — <a href=index.html>Table of Contents</a> — <a href=server-sent-events.html>9.2 Server-sent events →</a></nav><ol class=toc><li id=toc-comms><a href=comms.html#comms><span class=secno>9</span> Communication</a><ol><li><a href=comms.html#the-messageevent-interface><span class=secno>9.1</span> The <code>MessageEvent</code> interface</a></ol></ol><h2 id=comms><span class=secno>9</span> Communication<a href=#comms class=self-link></a></h2>

  <p id=network class=note><a href=#network class=self-link></a><span id=network-intro></span><span id=the-websocket-interface></span><span id=feedback-from-the-protocol></span><span id=ping-and-pong-frames></span><span id=the-closeevent-interface></span><span id=garbage-collection-2></span><span id=websocket></span><span id=binarytype></span><span id=closeevent></span><span id=closeeventinit></span>The <code id=comms:websocket-2><a data-x-internal=websocket-2 href=https://websockets.spec.whatwg.org/#websocket>WebSocket</a></code> interface used
  to be defined here. It is now defined in <cite>WebSockets</cite>. <a href=references.html#refsWEBSOCKETS>[WEBSOCKETS]</a></p>

  <h3 id=the-messageevent-interface><span class=secno>9.1</span> The <code id=the-messageevent-interface:messageevent><a href=#messageevent>MessageEvent</a></code> interface<a href=#the-messageevent-interface class=self-link></a></h3><div class="mdn-anno wrapped"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent title="The MessageEvent interface represents a message received by a target object.">MessageEvent</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>10.6+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>11+</span></span></div></div></div>

  <p>Messages in <a id=the-messageevent-interface:server-sent-events href=server-sent-events.html#server-sent-events>server-sent events</a>, <a id=the-messageevent-interface:web-messaging href=web-messaging.html#web-messaging>cross-document messaging</a>,
  <a id=the-messageevent-interface:channel-messaging href=web-messaging.html#channel-messaging>channel messaging</a>, <a id=the-messageevent-interface:broadcasting-to-other-browsing-contexts href=web-messaging.html#broadcasting-to-other-browsing-contexts>broadcast channels</a>, and <cite>WebSockets</cite> use
  the <code id=the-messageevent-interface:messageevent-2><a href=#messageevent>MessageEvent</a></code> interface for their <code id=the-messageevent-interface:event-message><a href=indices.html#event-message>message</a></code>
  events: <a href=references.html#refsWEBSOCKETS>[WEBSOCKETS]</a></p>

  <pre><code class='idl'>[<c- g>Exposed</c->=(<c- n>Window</c->,<c- n>Worker</c->,<c- n>AudioWorklet</c->)]
<c- b>interface</c-> <dfn id='messageevent' data-dfn-type='interface'><c- g>MessageEvent</c-></dfn> : <a id='the-messageevent-interface:event' href='https://dom.spec.whatwg.org/#interface-event' data-x-internal='event'><c- n>Event</c-></a> {
  <a href='https://dom.spec.whatwg.org/#concept-event-constructor' id='the-messageevent-interface:dom-event-constructor' data-x-internal='dom-event-constructor'><c- g>constructor</c-></a>(<c- b>DOMString</c-> <c- g>type</c->, <c- b>optional</c-> <a href='#messageeventinit' id='the-messageevent-interface:messageeventinit'><c- n>MessageEventInit</c-></a> <c- g>eventInitDict</c-> = {});

  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>any</c-> <a href='#dom-messageevent-data' id='the-messageevent-interface:dom-messageevent-data'><c- g>data</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>USVString</c-> <a href='#dom-messageevent-origin' id='the-messageevent-interface:dom-messageevent-origin'><c- g>origin</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>DOMString</c-> <a href='#dom-messageevent-lasteventid' id='the-messageevent-interface:dom-messageevent-lasteventid'><c- g>lastEventId</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <a href='#messageeventsource' id='the-messageevent-interface:messageeventsource'><c- n>MessageEventSource</c-></a>? <a href='#dom-messageevent-source' id='the-messageevent-interface:dom-messageevent-source'><c- g>source</c-></a>;
  <c- b>readonly</c-> <c- b>attribute</c-> <c- b>FrozenArray</c->&lt;<a id='the-messageevent-interface:messageport' href='web-messaging.html#messageport'><c- n>MessagePort</c-></a>&gt; <a href='#dom-messageevent-ports' id='the-messageevent-interface:dom-messageevent-ports'><c- g>ports</c-></a>;

  <c- b>undefined</c-> <a href='#dom-messageevent-initmessageevent' id='the-messageevent-interface:dom-messageevent-initmessageevent'><c- g>initMessageEvent</c-></a>(<c- b>DOMString</c-> <c- g>type</c->, <c- b>optional</c-> <c- b>boolean</c-> <c- g>bubbles</c-> = <c- b>false</c->, <c- b>optional</c-> <c- b>boolean</c-> <c- g>cancelable</c-> = <c- b>false</c->, <c- b>optional</c-> <c- b>any</c-> <c- g>data</c-> = <c- b>null</c->, <c- b>optional</c-> <c- b>USVString</c-> <c- g>origin</c-> = &quot;&quot;, <c- b>optional</c-> <c- b>DOMString</c-> <c- g>lastEventId</c-> = &quot;&quot;, <c- b>optional</c-> <a href='#messageeventsource' id='the-messageevent-interface:messageeventsource-2'><c- n>MessageEventSource</c-></a>? <c- g>source</c-> = <c- b>null</c->, <c- b>optional</c-> <c- b>sequence</c->&lt;<a id='the-messageevent-interface:messageport-2' href='web-messaging.html#messageport'><c- n>MessagePort</c-></a>&gt; <c- g>ports</c-> = []);
};

<c- b>dictionary</c-> <dfn id='messageeventinit' data-dfn-type='dictionary'><c- g>MessageEventInit</c-></dfn> : <a id='the-messageevent-interface:eventinit' href='https://dom.spec.whatwg.org/#dictdef-eventinit' data-x-internal='eventinit'><c- n>EventInit</c-></a> {
  <c- b>any</c-> <dfn data-dfn-for='MessageEventInit' id='dom-messageeventinit-data' data-dfn-type='dict-member'><c- g>data</c-></dfn> = <c- b>null</c->;
  <c- b>USVString</c-> <dfn data-dfn-for='MessageEventInit' id='dom-messageeventinit-origin' data-dfn-type='dict-member'><c- g>origin</c-></dfn> = &quot;&quot;;
  <c- b>DOMString</c-> <dfn data-dfn-for='MessageEventInit' id='dom-messageeventinit-lasteventid' data-dfn-type='dict-member'><c- g>lastEventId</c-></dfn> = &quot;&quot;;
  <a href='#messageeventsource' id='the-messageevent-interface:messageeventsource-3'><c- n>MessageEventSource</c-></a>? <dfn data-dfn-for='MessageEventInit' id='dom-messageeventinit-source' data-dfn-type='dict-member'><c- g>source</c-></dfn> = <c- b>null</c->;
  <c- b>sequence</c->&lt;<a id='the-messageevent-interface:messageport-3' href='web-messaging.html#messageport'><c- n>MessagePort</c-></a>&gt; <dfn data-dfn-for='MessageEventInit' id='dom-messageeventinit-ports' data-dfn-type='dict-member'><c- g>ports</c-></dfn> = [];
};

<c- b>typedef</c-> (<a id='the-messageevent-interface:windowproxy' href='nav-history-apis.html#windowproxy'><c- n>WindowProxy</c-></a> <c- b>or</c-> <a id='the-messageevent-interface:messageport-4' href='web-messaging.html#messageport'><c- n>MessagePort</c-></a> <c- b>or</c-> <a id='the-messageevent-interface:serviceworker' href='https://w3c.github.io/ServiceWorker/#serviceworker' data-x-internal='serviceworker'><c- n>ServiceWorker</c-></a>) <dfn id='messageeventsource' data-dfn-type='typedef'><c- g>MessageEventSource</c-></dfn>;</code></pre>

  <dl class=domintro><dt><code><var>event</var>.<a href=#dom-messageevent-data id=dom-messageevent-data-dev>data</a></code><div class="mdn-anno wrapped before"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data title="The data read-only property of the MessageEvent interface represents the data sent by the message emitter.">MessageEvent/data</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dd><p>Returns the data of the message.<dt><code><var>event</var>.<a href=#dom-messageevent-origin id=dom-messageevent-origin-dev>origin</a></code><div class="mdn-anno wrapped before"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/origin title="The origin read-only property of the MessageEvent interface is a string representing the origin of the message emitter.">MessageEvent/origin</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dd>
    <p>Returns the origin of the message, for <a id=the-messageevent-interface:server-sent-events-2 href=server-sent-events.html#server-sent-events>server-sent events</a> and
    <a id=the-messageevent-interface:web-messaging-2 href=web-messaging.html#web-messaging>cross-document messaging</a>.</p>
   <dt><code><var>event</var>.<a href=#dom-messageevent-lasteventid id=dom-messageevent-lasteventid-dev>lastEventId</a></code><div class="mdn-anno wrapped before"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/lastEventId title="The lastEventId read-only property of the MessageEvent interface is a string representing a unique ID for the event.">MessageEvent/lastEventId</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>17+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dd>
    <p>Returns the <a href=server-sent-events.html#concept-event-stream-last-event-id id=the-messageevent-interface:concept-event-stream-last-event-id>last event ID string</a>,
    for <a id=the-messageevent-interface:server-sent-events-3 href=server-sent-events.html#server-sent-events>server-sent events</a>.</p>
   <dt><code><var>event</var>.<a href=#dom-messageevent-source id=dom-messageevent-source-dev>source</a></code><div class="mdn-anno wrapped before"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/source title="The source read-only property of the MessageEvent interface is a MessageEventSource (which can be a WindowProxy, MessagePort, or ServiceWorker object) representing the message emitter.">MessageEvent/source</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>2+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie no"><span>Internet Explorer</span><span>No</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dd>
    <p>Returns the <code id=the-messageevent-interface:windowproxy-2><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code> of the source window, for <a id=the-messageevent-interface:web-messaging-3 href=web-messaging.html#web-messaging>cross-document
    messaging</a>, and the <code id=the-messageevent-interface:messageport-5><a href=web-messaging.html#messageport>MessagePort</a></code> being attached, in the <code id=the-messageevent-interface:event-workerglobalscope-connect><a href=indices.html#event-workerglobalscope-connect>connect</a></code> event fired at
    <code id=the-messageevent-interface:sharedworkerglobalscope><a href=workers.html#sharedworkerglobalscope>SharedWorkerGlobalScope</a></code> objects.</p>
   <dt><code><var>event</var>.<a href=#dom-messageevent-ports id=dom-messageevent-ports-dev>ports</a></code><div class="mdn-anno wrapped before"><button onclick=toggleStatus(this) class=mdn-anno-btn><b title="Support in all current engines." class=all-engines-flag>✔</b><span>MDN</span></button><div class=feature><p><a href=https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/ports title="The ports read-only property of the MessageEvent interface is an array of MessagePort objects representing the ports associated with the channel the message is being sent through (where appropriate, e.g. in channel messaging or when sending a message to a shared worker).">MessageEvent/ports</a><p class=all-engines-text>Support in all current engines.<div class=support><span class="firefox yes"><span>Firefox</span><span>3+</span></span><span class="safari yes"><span>Safari</span><span>4+</span></span><span class="chrome yes"><span>Chrome</span><span>4+</span></span><hr><span class="opera yes"><span>Opera</span><span>12.1+</span></span><span class="edge_blink yes"><span>Edge</span><span>79+</span></span><hr><span class="edge yes"><span>Edge (Legacy)</span><span>12+</span></span><span class="ie yes"><span>Internet Explorer</span><span>9+</span></span><hr><span class="firefox_android unknown"><span>Firefox Android</span><span>?</span></span><span class="safari_ios unknown"><span>Safari iOS</span><span>?</span></span><span class="chrome_android unknown"><span>Chrome Android</span><span>?</span></span><span class="webview_android yes"><span>WebView Android</span><span>37+</span></span><span class="samsunginternet_android unknown"><span>Samsung Internet</span><span>?</span></span><span class="opera_android yes"><span>Opera Android</span><span>12.1+</span></span></div></div></div><dd>
    <p>Returns the <code id=the-messageevent-interface:messageport-6><a href=web-messaging.html#messageport>MessagePort</a></code> array sent with the message, for <a id=the-messageevent-interface:web-messaging-4 href=web-messaging.html#web-messaging>cross-document
    messaging</a> and <a id=the-messageevent-interface:channel-messaging-2 href=web-messaging.html#channel-messaging>channel messaging</a>.</p>
   </dl>

  

  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-data data-dfn-type=attribute><code>data</code></dfn>
  attribute must return the value it was initialized to. It represents the message being sent.</p>

  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-origin data-dfn-type=attribute><code>origin</code></dfn> attribute must return the value it was
  initialized to. It represents, in <a id=the-messageevent-interface:server-sent-events-4 href=server-sent-events.html#server-sent-events>server-sent events</a> and <a id=the-messageevent-interface:web-messaging-5 href=web-messaging.html#web-messaging>cross-document
  messaging</a>, the <a href=https://dom.spec.whatwg.org/#concept-document-origin id=the-messageevent-interface:concept-document-origin data-x-internal=concept-document-origin>origin</a> of the document that
  sent the message (typically the scheme, hostname, and port of the document, but not its path or
  <a href=https://url.spec.whatwg.org/#concept-url-fragment id=the-messageevent-interface:concept-url-fragment data-x-internal=concept-url-fragment>fragment</a>).</p>

  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-lasteventid data-dfn-type=attribute><code>lastEventId</code></dfn> attribute must return the value it
  was initialized to. It represents, in <a id=the-messageevent-interface:server-sent-events-5 href=server-sent-events.html#server-sent-events>server-sent events</a>, the <a href=server-sent-events.html#concept-event-stream-last-event-id id=the-messageevent-interface:concept-event-stream-last-event-id-2>last event ID string</a> of the event source.</p>

  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-source data-dfn-type=attribute><code>source</code></dfn> attribute must return the value it was
  initialized to. It represents, in <a id=the-messageevent-interface:web-messaging-6 href=web-messaging.html#web-messaging>cross-document messaging</a>, the
  <code id=the-messageevent-interface:windowproxy-3><a href=nav-history-apis.html#windowproxy>WindowProxy</a></code> of the <a id=the-messageevent-interface:browsing-context href=document-sequences.html#browsing-context>browsing context</a> of the <code id=the-messageevent-interface:window><a href=nav-history-apis.html#window>Window</a></code> object
  from which the message came; and in the <code id=the-messageevent-interface:event-workerglobalscope-connect-2><a href=indices.html#event-workerglobalscope-connect>connect</a></code> events used by <a href=workers.html#sharedworkerglobalscope id=the-messageevent-interface:sharedworkerglobalscope-2>shared workers</a>, the newly connecting
  <code id=the-messageevent-interface:messageport-7><a href=web-messaging.html#messageport>MessagePort</a></code>.</p>

  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-ports data-dfn-type=attribute><code>ports</code></dfn>
  attribute must return the value it was initialized to. It represents, in <a id=the-messageevent-interface:web-messaging-7 href=web-messaging.html#web-messaging>cross-document
  messaging</a> and <a id=the-messageevent-interface:channel-messaging-3 href=web-messaging.html#channel-messaging>channel messaging</a>, the <code id=the-messageevent-interface:messageport-8><a href=web-messaging.html#messageport>MessagePort</a></code> array being
  sent.</p>

  
  <p>The <dfn data-dfn-for=MessageEvent id=dom-messageevent-initmessageevent data-dfn-type=method><code>initMessageEvent(<var>type</var>, <var>bubbles</var>,
  <var>cancelable</var>, <var>data</var>, <var>origin</var>, <var>lastEventId</var>,
  <var>source</var>, <var>ports</var>)</code></dfn> method must initialize the event in a manner
  analogous to the similarly-named <code id=the-messageevent-interface:dom-event-initevent><a data-x-internal=dom-event-initevent href=https://dom.spec.whatwg.org/#dom-event-initevent>initEvent()</a></code> method.
  <a href=references.html#refsDOM>[DOM]</a></p>

  

  <p class=note>Various APIs (e.g., <code id=the-messageevent-interface:websocket-2><a data-x-internal=websocket-2 href=https://websockets.spec.whatwg.org/#websocket>WebSocket</a></code>, <code id=the-messageevent-interface:eventsource><a href=server-sent-events.html#eventsource>EventSource</a></code>) use the
  <code id=the-messageevent-interface:messageevent-3><a href=#messageevent>MessageEvent</a></code> interface for their <code id=the-messageevent-interface:event-message-2><a href=indices.html#event-message>message</a></code> event
  without using the <code id=the-messageevent-interface:messageport-9><a href=web-messaging.html#messageport>MessagePort</a></code> API.</p>


  <nav><a href=imagebitmap-and-animations.html>← 8.10 Images</a> — <a href=index.html>Table of Contents</a> — <a href=server-sent-events.html>9.2 Server-sent events →</a></nav>
